import 'dart:math';

import 'package:whale/helper/utils/httputils/result_data.dart';

import '../../../helper/component/base/casstle/index.dart';
import '../../../helper/component/base/model/page.dart';
import '../../../helper/utils/util.dart';
import '../../refresh_demo/model.dart';
import 'index.dart';

class CasstleDemo_2Controller extends CasstleController<CasstleDemo_2State> {
  CasstleDemo_2Controller();

  /// 在 widget 内存中分配后立即调用。
  @override
  void onInit() {
    super.onInit();
  }

  /// 在 onInit() 之后调用 1 帧。这是进入的理想场所
  @override
  void onReady() {
    super.onReady();
  }

  /// 在 [onDelete] 方法之前调用。
  @override
  void onClose() {
    super.onClose();
  }

  /// dispose 释放内存
  @override
  void dispose() {
    super.dispose();
  }

  @override
  CasstleDemo_2State createState() {
    return CasstleDemo_2State();
  }

  @override
  CasstleDemo_2Controller createController() {
    return CasstleDemo_2Controller();
  }

  @override
  Future<NetBaseReponse> onRequest({int? current}) async {
    Hud.show();
    await Future.delayed(Duration(seconds: 1));
    Hud.dismiss();
    return NetBaseReponse.response(
      res: NetReponse.fromJson(_getData()),
      fromJsonT: (json) =>
          PageModel.fromJson(json, (json) => RefreshDemoModel.fromJson(json)),
    );
  }

  Dictionary _getData() {
    return {
      "code": 0,
      "msg": null,
      "data": {
        "records": [
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "0ef0f900-573b-489a-be31-9d0d3c6df887",
            "meetingName": "dcvdvdcdrcec",
            "meetingTime": "2024-03-25 11:00~2024-03-26 11:00",
            "meetingPlace": "901",
            "participants": "射雕一组(郭靖)",
            "meetingStatus": "4",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "1588ff8f-554e-4c01-a631-e8fb8102d6ed",
            "meetingName": "外部会议，部门负责人修改会议室",
            "meetingTime": "2023-12-09 08:30~2023-12-09 10:30",
            "meetingPlace": "901",
            "participants": "射雕二组(黄蓉、郭芙、郭襄)",
            "meetingStatus": "5",
            "createBy": "3075ad0d-ccba-4c5f-b3b7-6bf58f421d16",
            "createByName": "大武",
            "enclosureList": []
          },
          {
            "id": "dfb426f3-17b1-410e-964f-041ce5123848",
            "meetingName": "外部会议",
            "meetingTime": "2024-01-08 14:00~2024-01-08 18:00",
            "meetingPlace": "901",
            "participants":
                "射雕集团(王重阳、一灯大师、洪七公、黄药师、欧阳锋、管理员名字修改、管理员名字修改)、射雕一组(郭靖、大武、小武)",
            "meetingStatus": "5",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": [
              {
                "id": "9322f9fa-96f8-4600-9851-99ce7b85975a",
                "name": "镜湖区公务员平时考核2022年度考核等次汇总.xlsx",
                "duration": "0",
                "sourcePath":
                    "https://jixiao.inspirestar.cn/group1/default/20230926/13/44/7/a49a72c3-6db0-426b-bdfb-7f35669b708d.xlsx?download=0",
                "thumbnailPath":
                    "https://jixiao.inspirestar.cn/group1/default/20240105/15/33/7/772f66bc-fd3d-437c-a571-45849b93fb09.pdf?download=0",
                "fileType": "xlsx"
              }
            ]
          },
          {
            "id": "d0e119f3-884b-489a-b789-e84051f656be",
            "meetingName": "外部会议",
            "meetingTime": "2024-01-24 13:00~2024-01-24 15:00",
            "meetingPlace": "901",
            "participants": "射雕二组(郭襄、郭芙、黄蓉)、射雕一组(小武、大武、郭靖)",
            "meetingStatus": "5",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "958f48c9-fc91-4cc4-9ac3-0e53ceef9c35",
            "meetingName": "待开始",
            "meetingTime": "2024-02-05 18:00~2024-02-05 19:00",
            "meetingPlace": "903",
            "participants": "射雕一组(管理员名字修改、小武、大武、郭靖)",
            "meetingStatus": "5",
            "createBy": "822bc822-19b9-4949-b233-dd7c022cfe76",
            "createByName": "郭靖",
            "enclosureList": []
          },
          {
            "id": "38ff8fbc-8922-41e0-aa62-b50b93588bb1",
            "meetingName": "外部会议",
            "meetingTime": "2024-02-06 09:00~2024-02-06 10:00",
            "meetingPlace": "901",
            "participants":
                "射雕二组(郭芙、黄蓉)、射雕五组(朱聪、柯镇恶)、射雕集团(洪七公、一灯大师、王重阳)、射雕四组(杨过)、射雕一组(大武、郭靖)",
            "meetingStatus": "5",
            "createBy": "37cad335-d37b-43be-84e2-7a93b9cd8d82",
            "createByName": "朱聪",
            "enclosureList": [
              {
                "id": "f8a655c8-5e76-4ef6-81ad-4f9bd0a8e9e7",
                "name":
                    "Screenshot_20240206_094147_com.topnet.assessmentFlu.jpg",
                "duration": "0",
                "sourcePath":
                    "https://jixiao.inspirestar.cn/group1/default/20240206/09/46/7/4d3f6d27-4e8f-4db3-a4a2-8fb1aa6d2087.jpg?download=0",
                "thumbnailPath":
                    "https://jixiao.inspirestar.cn/group1/default/20240206/09/46/7/1ee42ea6-1b54-403a-9e4f-23db38645b07.jpg?download=0",
                "fileType": "jpg"
              }
            ]
          },
          {
            "id": "b3246e90-8f93-412f-b55d-cf9a62f889a8",
            "meetingName": "审批取消会议",
            "meetingTime": "2024-02-06 17:00~2024-02-07 17:00",
            "meetingPlace": "903",
            "participants":
                "射雕二组(郭芙、黄蓉)、射雕三组(杨二、杨一)、射雕集团(管理员名字修改、洪七公、一灯大师、王重阳)、射雕一组(大武、郭靖)",
            "meetingStatus": "5",
            "createBy": "3075ad0d-ccba-4c5f-b3b7-6bf58f421d16",
            "createByName": "大武",
            "enclosureList": []
          },
          {
            "id": "f2006588-b1d6-47b3-9f48-aae0f8b9a078",
            "meetingName": "妥妥",
            "meetingTime": "2024-02-06 17:00~2024-02-06 18:00",
            "meetingPlace": "901",
            "participants": "射雕集团(黄药师、洪七公、一灯大师)、射雕一组(小武、大武、郭靖)",
            "meetingStatus": "5",
            "createBy": "3075ad0d-ccba-4c5f-b3b7-6bf58f421d16",
            "createByName": "大武",
            "enclosureList": []
          }
        ],
        "total": 18,
        "size": 10,
        "current": 1,
        "orders": [],
        "optimizeCountSql": true,
        "searchCount": true,
        "countId": null,
        "maxLimit": null,
        "pages": 2
      }
    };
  }

  @override
  Future<void> requestForTabTitles() async {
    setupTabData(
        List.generate(Random().nextInt(8) + 2, (index) => '第$index个'), 0);
  }

  @override
  String idenPrefix() {
    return 'demo2';
  }
}
